
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style type="text/css">
 
  </style>
</head>
<body>
  <div id="app">
    <div>
    名： <input type="text" name="" id="" v-model="ming">
      
    </div>
    <div>
    姓： <input type="text" name="" id="" v-model="xing">
      
    </div>
    <div>{{fullname}}</div>
  </div>

  <script type="text/javascript" src="./js/vue.js"></script>
  <script type="text/javascript">
    /*
      侦听器
    */
    var vm = new Vue({
      el: '#app',
    data: {
      ming: "lvhang",
      xing: "lvcheng",
      // fullname: "lvhang lvchengxin"
      },
      computed: {
        fullname: function() {
          return this.ming + ' ' + this.xing;
        }
      },
    // 侦听器 watch
    watch: {
        // ming(val) {
        //   this.fullname = val + ' ' + this.xing;
        // },
        // xing(val) {
        //   this.fullname = this.ming + ' ' + val; 
        // }

      }
    });
  </script>
</body>
</html>
